package org.xbs.demo1.result;

import lombok.Data;
//结果类，后端返回的数据都以这个形式返回
@Data
public class Result {
    private String code;
    private static final String successcode= "1";//传给前端的自定义状态码，0为失败，1为成功
    private static final String failcode= "0";
    private String message;
    private Object data;
    public Result(String code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public static Result success(Object data) {
        return new Result(Result.successcode,"success",data);
    }//返回数据的success（）方法
    public static Result success() {
        return new Result(Result.successcode,"success",null);
    }//不返回数据的success（）方法
    public static Result fail(Object data) {
        return new Result(Result.failcode,"fail",data);
    }//返回数据的fall（）方法
    public static Result fail() {
        return new Result(Result.failcode,"fail",null);
    }//不返回数据的fall（）方法
}
